<?php

function make_publish_links($article_id){
	if ($article_id == '') return 'No id';
		
	$query = "SELECT pageId FROM articleFeeds WHERE articleId = $article_id";
	
	$feed_pages = array(
		'24' => 'Home',
		'31' => 'Casuality',
		'32' => 'Property',
		'33' => 'Energy',
		'34' => 'Professional Services',
		'35' => 'Transportation',
		'36' => 'Underwriting'
	);
	
	$results = mysql_query($query);
	
	$fed = array();
	$fedHtml = '';
	
	if(mysql_num_rows($results) > 0){
		$fedHtml = 'Published to:';
	}
	
	while ($row = mysql_fetch_assoc($results)){
		$page_id = $row['pageId'];
		$fed[$page_id]= $page_id;
		$fedHtml .= '<br><a onclick="remove_feed(event, '.$article_id.', '.$page_id.');" href="javascript:void(0);"">X</a> '.$feed_pages[$page_id];
	}
	
	$newsFeedDropdown = '';
	
	foreach ($feed_pages as $page_id => $page){
		if (!isset($fed[$page_id])){
			$newsFeedDropdown .= "<option value='$page_id'>$page</option>";
		}
	}
	
	if ($newsFeedDropdown != ''){
		$newsFeedDropdown = 'Publish to:  <select class="add_feed_doc_id">'.$newsFeedDropdown.'</select><a onclick="add_feed(event);" href="javascript:void(0)l">Go</a><br>';
	}
	
	$o = $newsFeedDropdown.$fedHtml;
	
	
	return $o;
}

?>